<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox-content">
                <div class="row">
                    <form action="<?=url('service.repair/create')?>" id="form-create" method="post" class="form-horizontal" role="form">
                        <link rel="stylesheet" type="text/css" href="/public/common/webuploader-0.1.5/webuploader.css">
                        <script type="text/javascript" src="/public/common/webuploader-0.1.5/webuploader.js"></script>
                        <div class="form-group">
                            <label class="col-sm-3 control-label no-padding-right"><span
                                    class="c-red">*</span>列表图片：</label>
                            <div class="col-sm-9 ">
                                <div id="uploader-demo" style="max-width: 300px">
                                    <!--用来存放item-->
                                    <div id="photoList" class="uploader-list">
                                        <?php if(isset($detail['photo'])){?>
                                        <div class="file-item thumbnail"><img width="110" src="/attachs/uploads/<?=$detail['photo']?>"><input type="hidden" value="<?=$detail['photo']?>" name="photo" id="photo"></div>
                                        <?php }?>
                                    </div>
                                    <div id="photoPicker">选择图片</div>
                                </div>
                            </div>
                        </div>
                        <script>
                            var uploaderphoto = WebUploader.create({
                                auto: true,
                                swf: '/public/admin/Widget/webuploader-0.1.5/Uploader.swf',
                                server: '<?=url("upload.upload/index",['mdl'=>"repair_photo"])?>',
                                pick: '#photoPicker',
                                resize: false,
                                duplicate: true
                            });

                            $(document).on('click', '.file-item', function () {
                                $(this).remove();
                            });

                            // 当有文件添加进来的时候
                            uploaderphoto.on('fileQueued', function (file) {
                                var $li = $(
                                    '<div id="' + file.id + '" class="file-item thumbnail">' +
                                    '<img>' +
                                    '<input type="hidden" value="" name="photo" id="photo">' +
                                    '<div class="info">' + file.name + '</div>' +
                                    '</div>'
                                    ),
                                    $img = $li.find('img');


                                // $list为容器jQuery实例
                                $("#photoList").html($li);

                                // 创建缩略图
                                // 如果为非图片文件，可以不用调用此方法。
                                // thumbnailWidth x thumbnailHeight 为 100 x 100
                                uploaderphoto.makeThumb(file, function (error, src) {
                                    if (error) {
                                        $img.replaceWith('<span>不能预览</span>');
                                        return;
                                    }

                                    $img.attr('src', src);
                                }, 100, 100);
                            });


                            // 文件上传过程中创建进度条实时显示。
                            uploaderphoto.on('uploadProgress', function (file, percentage) {
                                var $li = $('#' + file.id),
                                    $percent = $li.find('.progress span');

                                // 避免重复创建
                                if (!$percent.length) {
                                    $percent = $('<p class="progress"><span></span></p>')
                                        .appendTo($li)
                                        .find('span');
                                }

                                $percent.css('width', percentage * 100 + '%');
                            });

                            // 文件上传成功，给item添加成功class, 用样式标记上传成功。
                            uploaderphoto.on('uploadSuccess', function (file, response) {
                                $('#' + file.id).addClass('upload-state-done');
                                $("#photo").val(response._raw);
                            });

                            // 文件上传失败，显示上传出错。
                            uploaderphoto.on('uploadError', function (file) {
                                var $li = $('#' + file.id),
                                    $error = $li.find('div.error');

                                // 避免重复创建
                                if (!$error.length) {
                                    $error = $('<div class="error"></div>').appendTo($li);
                                }

                                $error.text('上传失败');
                            });

                            // 完成上传完了，成功或者失败，先删除进度条。
                            uploaderphoto.on('uploadComplete', function (file) {
                                $('#' + file.id).find('.progress').remove();
                            });

                        </script>
                        <div class="form-group">
                            <label class="col-sm-3 control-label no-padding-right"><span class="c-red">*</span>分类：</label>
                            <div class="col-sm-9">
                                <select class="form-control m-b" name="category_id" id="category_id">
                                    <option value="0">请选择</option>
                                    <?php foreach($category as $val) {?>
                                    <option value="<?=$val->category_id?>"><?=$val->name?></option>
                                    <?php } ?>
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label no-padding-right"><span class="c-red">*</span>标题：</label>
                            <div class="col-sm-9">
                                <input type="text" value="<?=isset($detail->title)?$detail->title:''?>" placeholder="" id="title" name="title" class="form-control"/>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label no-padding-right"><span class="c-red">*</span>副标题：</label>
                            <div class="col-sm-9">
                                <input type="text" value="<?=isset($detail->title2)?$detail->title2:''?>" placeholder="" id="title2" name="title2" class="form-control"/>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label no-padding-right"><span class="c-red">*</span>预约价格：</label>
                            <div class="col-sm-9">
                                <input type="text" value="<?=isset($detail->price)?$detail->price:''?>" placeholder="" id="price" name="price" class="form-control"/>
                            </div>
                        </div>
                        <div id="type">
                            <div class="form-group">
                                <label class="col-sm-3 control-label no-padding-right"><span class="c-red">*</span>服务项目价格表：</label>
                                <div class="col-sm-2">
                                    服务名称
                                    <input type="text" value="" placeholder="如：扫地" name="data[name][]" class="form-control"/>
                                </div>
                                <div class="col-sm-2">
                                    价格
                                    <input type="text" value="" placeholder="价格" name="data[price][]" class="form-control"/>
                                </div>
                                <div class="col-sm-2">
                                    活动价格
                                    <input type="text" value="" placeholder="活动价格" name="data[hd_price][]" class="form-control"/>
                                </div>
                                <div class="col-sm-2">
                                    <i style="margin-top: 5%;margin-right: 10px;cursor:pointer" class=" btn-add ace-icon fa fa-plus bigger-110 fa-3x"></i>
                                    <i style="margin-top: 5%;cursor:pointer" class="btn-del ace-icon fa  fa-minus bigger-110 fa-3x"></i>
                                </div>
                            </div>
                        </div>
                        <script>
                            $(document).on('click', '.btn-add', function () {
                                $("#type").append($(this).parent().parent().clone(true));
                            })
                            $(document).on('click', '.btn-del', function () {
                                if ($('.btn-add').length <= 1) {
                                    layer.msg('最少添加一个');
                                } else {
                                    var _this = $(this);
                                    layer.confirm('确定删除吗?', {
                                        btn: ['确定', '取消'] //按钮
                                    }, function () {
                                        layer.closeAll();//关闭所有的窗口
                                        _this.parent().parent().remove();
                                    });
                                }
                            })
                        </script>
                        <div class="form-group">
                            <label class="col-sm-3 control-label no-padding-right"><span class="c-red">*</span>介绍：</label>
                            <div class="col-sm-9">
                                <textarea name="introduce" placeholder="说点什么...最少输入10个字符" id="introduce" cols="50" rows="10" class="form-control"><?=isset($detail->introduce)?$detail->introduce:''?></textarea>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label no-padding-right"><span class="c-red">*</span>推荐到首页：</label>
                            <div class="col-sm-1">
                                <div class="radio i-checks">
                                    <label><input name="is_hot" id="is_hot" value="1" type="radio" <?php if(isset($detail->is_hot)&& $detail->is_hot==1){?>checked="checked"<?php }?> > <i></i> 是</label>
                                    <label><input name="is_hot" id="is_hot" value="0" type="radio" <?php if(isset($detail->is_hot)&& $detail->is_hot==0){?>checked="checked"<?php }?> > <i></i> 否</label>
                                </div>
                            </div>
                            <div class="col-sm-7" style="text-align: left;line-height: 30px;">
                                    请适当推荐 您最多可以推荐 63 个服务
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label no-padding-right"><span class="c-red">*</span>排序：</label>
                            <div class="col-sm-9">
                                <input type="text" value="<?=isset($detail->orderby)?$detail->orderby:''?>" placeholder="" id="orderby" name="orderby" class="form-control"/>
                            </div>
                        </div>
                        <div class="clearfix form-actions">
                            <div class="col-md-offset-3 col-md-9">
                                <button mini="submit" for="form-create" class="btn btn-info" type="button">
                                    <i class="ace-icon fa fa-check bigger-110"></i>
                                    保存
                                </button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>